<?php
$reviewdetails = Reviews::getAllReview('courses_id', $model->id);
if (!empty($reviewdetails)) {
    $i = 1;
    foreach ($reviewdetails as $key => $value) {
        $profile = Users::getFrontEndUser($value->users_id);
     
        $imgsrcs = (!empty($profile->photo)) ? getRequestbaseUrl() . getuploadFolderDir() . $value->users_id . '/profile/minithumb/' . $profile->photo : getWorkNoshopimage(SkillConfig::skill_myinbox_image);
        ?>
        <div class="item <?php echo ($i == 1) ? 'active' : ''; ?>"> 
            <div class="single-review">
                <a href="#">
                    <img src="<?php echo $imgsrcs; ?>" alt="">
                    <div class="review-info">
                        <div class="name"><?php echo!empty($profile->first_name) ? $profile->first_name . '   ' . $profile->last_name : SkillConfig::SKILL_NO_USERNAME; ?></div>
                        <div class="title"><?php echo substr($value->reviews_text, 0, 70).'...'; ?></div>
                    </div>
                </a>
            </div><!--single-review-->
            <hr>

        </div>
        <?php
    }
} else {
    echo ' <div class="single-review"><div class="review-info">' . Message::NO_REVIEWS_MSG_COURSE . '</div></div>';
}
?>

<?php
$afterLoginUser = Users::getFrontEndUser(getLoginUserId());
if (!empty($afterLoginUser)) {
    $imgsrc = (!empty($afterLoginUser->photo)) ? getRequestbaseUrl() . getuploadFolderDir() . getLoginUserId() . '/profile/minithumb/' . $afterLoginUser->photo : getWorkNoshopimage(SkillConfig::skill_myinbox_image);
    ?>
    <div class="single-review">              
        <img src="<?php echo $imgsrc; ?>" alt="">
        <div class="review-info">
            <form class="form-inline" role="form">
                <div class="form-group">
                    <input type="text" class="form-control review-form" id="review-text" placeholder="Add a review">
                </div>
            </form> 
        </div>              
    </div>

<?php } else { ?>
    <input type="submit" class="btn review-btn"  id="review-text" value="Write a Review">
<?php } ?>